<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>消费者订单页面</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f9f9f9;
            padding: 20px;
        }
        .container {
            max-width: 800px;
            margin: auto;
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        h2 {
            text-align: center;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        th, td {
            padding: 10px;
            text-align: left;
            border-bottom: 1px solid #ccc;
        }
        th {
            background-color: #007bff;
            color: white;
        }
        tr:hover {
            background-color: #f1f1f1;
        }
        button {
            padding: 5px 10px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0,0,0,0.4);
            padding-top: 60px;
        }
        .modal-content {
            background-color: #fefefe;
            margin: 5% auto;
            padding: 20px;
            border: 1px solid #888;
            width: 80%;
            max-width: 400px;
            border-radius: 8px;
        }
        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
        }
        .close:hover,
        .close:focus {
            color: black;
            text-decoration: none;
            cursor: pointer;
        }
    </style>
</head>
<body>

<div class="container">
    <h2>我的订单</h2>
    <table>
        <thead>
            <tr>
                <th>订单ID</th>
                <th>商品名称</th>
                <th>数量</th>
                <th>价格</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody id="order-list">
            <tr>
                <td>1001</td>
                <td>商品A</td>
                <td>2</td>
                <td>￥100</td>
                <td>已发货</td>
                <td>
                    <button onclick="trackLogistics('1001')">物流查询</button>
                    <button onclick="openAfterSalesModal('1001')">售后</button>
                </td>
            </tr>
            <tr>
                <td>1002</td>
                <td>商品B</td>
                <td>1</td>
                <td>￥50</td>
                <td>待发货</td>
                <td>
                    <button onclick="trackLogistics('1002')">物流查询</button>
                    <button onclick="openAfterSalesModal('1002')">售后</button>
                </td>
            </tr>
            <tr>
                <td>1003</td>
                <td>商品C</td>
                <td>5</td>
                <td>￥250</td>
                <td>已送达</td>
                <td>
                    <button onclick="trackLogistics('1003')">物流查询</button>
                    <button onclick="openAfterSalesModal('1003')">售后</button>
                </td>
            </tr>
        </tbody>
    </table>
</div>

<!-- 售后模态框 -->
<div id="afterSalesModal" class="modal">
    <div class="modal-content">
        <span class="close" onclick="closeAfterSalesModal()">&times;</span>
        <h2>售后服务</h2>
        <p>请选择售后类型：</p>
        <button onclick="processAfterSales('换货')">换货</button>
        <button onclick="processAfterSales('退货退款')">退货退款</button>
        <button onclick="processAfterSales('仅退款')">仅退款</button>
    </div>
</div>

<script>
    function trackLogistics(orderId) {
        alert(`查询订单 ${orderId} 的物流信息...`);
        // 在这里可以添加实际的物流查询逻辑
    }

    function openAfterSalesModal(orderId) {
        document.getElementById('afterSalesModal').style.display = "block";
        // 可以存储订单ID以供后续处理
    }

    function closeAfterSalesModal() {
        document.getElementById('afterSalesModal').style.display = "none";
    }

    function processAfterSales(type) {
        alert(`已选择售后类型：${type}`);
        // 在这里可以添加实际的售后处理逻辑
        closeAfterSalesModal();
    }

    // 点击窗口外部关闭模态框
    window.onclick = function(event) {
        const modal = document.getElementById('afterSalesModal');
        if (event.target === modal) {
            closeAfterSalesModal();
        }
    };
</script>

</body>
</html>
